package com.hj.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hj.pojo.User;

@Controller
@RequestMapping("/user2")
public class UserController2 {

	List<User> userList = new java.util.concurrent.CopyOnWriteArrayList<>();
	
	public UserController2() {
		userList.add(new User("1", "admin", "nan", "18"));
		userList.add(new User("2", "test", "nv", "20"));
	}
	
	@GetMapping
	public String findAll(HttpServletRequest request) {
		request.setAttribute("ulist", userList);
		request.setAttribute("uname", "小明");
		request.setAttribute("link", "https://www.baidu.com");
		return "userList";
	}
		
}
